import 'package:flutter/material.dart';

/// @date 2020/07/20  17:43
/// @author 程志强
/// @des ListView.separated 列表之间添加分隔线

class SeparatedListViewRoute extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    Widget divider1 = Divider(color: Colors.blue);
    Widget divider2 = Divider(color: Colors.red);
    return Scaffold(
      appBar: AppBar(
        title: Text("ListView.separated"),
      ),
      body: ListView.separated(
          itemCount: 100,
          itemBuilder: (context, index) {
            return ListTile(
              title: Text("$index"),
            );
          },
          // 设置分隔线
          separatorBuilder: (context, index) {
            return index % 2 == 0 ? divider1 : divider2;
          }),

    );
  }
}
